<?php
defined('ROOTPATH') OR exit('Forbidden');

require_once ROOTPATH.'third_party/smarty/Smarty.class.php';

class view {

    public static $template = null;

    // 配置Smarty
    protected static function config() {
        if (self::$template->template_dir == '') {
            self::$template = new Smarty();
            self::$template->template_dir = ROOTPATH.'views/';
            self::$template->compile_dir = ROOTPATH.'cache/tpl';
            self::$template->left_delimiter ='<{';
            self::$template->right_delimiter='}>';
        }
    }

    // 重写Smarty注册变量方法
    public static function assign($label, $content) {
        self::config();
        self::$template->assign($label, $content);
    }

    // 重写Smarty调用视图文件方法
    public static function display($filename) {
        self::config();
        self::$template->display($filename.'.tpl');
    }
}
